<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%     
	String path = request.getContextPath();     
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";     
%>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>新增费用管理</title>
	<base href="<%=basePath%>"/>
	<%@ include file="../../cuv_include.jsp"%>
	<style type="text/css"> 
	  fieldset,legend,form,table,tr,td,textarea{margin:0;padding:0}
	  form label {font-weight:bold;}
	  table{margin:10px 10px};
	  td{line-height: 40px;}
	  input[type="text"]{width:250px;}
	  input[type="password"]{width:250px;}
	  input[type="textarea"]{width:250px;}
	  textarea{width:250px;}	
	</style>

<script type="text/javascript">
  $(document).ready(function(){
      $("#applyUser").focus();
      
      var options = {dataType: 'json', beforeSubmit: beforeSubmit, success: process};
      $("#actionForm").submit(function(){
    	  $("#btn_insert").attr("disabled","disabled");
          $(this).ajaxSubmit(options);
          return false;
      });
  });
  
  function beforeSubmit() {
      if(isEmpty($("#applyUser").val())) { 
    	  alert("申请人名称不能为空！"); 
	      $("#ben_insert").removeAttr("disabled");
	      return false;
	      }
      if(isEmpty($("#applyReason").val())) { 
    	  alert("申请事由不能为空！"); 
    	  $("#ben_insert").removeAttr("disabled");
    	  return false; 
    	  }
      if(isEmpty($("#expectCost").val())) {
    	  alert("预算金额不能为空！"); 
    	  $("#ben_insert").removeAttr("disabled");
    	  return false; 
    	  }
      return true;
  }
  
  function process(responseJson) {
	  $("#ben_insert").removeAttr("disabled");
      if(responseJson.code == 0) {
          $('#error_label').text("错误信息：" + responseJson.message);
          $("#p_error").show();
          return;
      }
      var qs = $("#qs").val();
      location.href = "<%=basePath%>pjcost/cost/userlist.do?" + qs;	  
  }  
</script>
</head>
<body>
<div style="width: 1208px;">
  <div>
    <fieldset>
      <legend>新增费用：</legend>
      <form id="actionForm" method="post" action="pjcost/cost/userinsert.do">
      	<input id="qs" name="qs" type="hidden" value="${qs}"/>
      	<p id = "p_error" style = "margin:10px 10px;">
      	    <label id="error_label" style="color:red;"></label>
      	</p>
        <table>
          <tr>
            <td><label for="applyUser">申请人：</label></td>
            <td>
            	<input type="text" name="applyUser" id="applyUser" value="${usercnname }" readonly="readonly" />
            	<font color="red">&nbsp;*&nbsp;&nbsp;</font>
            </td>
          </tr>
          <tr>
          	<td><label for="province">省份</label></td>
          	<td>
          		<select id="province" name="province" style="width:120px;">
                   <c:forEach items="${provinces}" var="pro" varStatus="status">
                   		<option value="${pro.key }">${pro.value }</option>
                   </c:forEach>
              	</select>   
              	<font color="red">&nbsp;*&nbsp;&nbsp;</font>       
          	</td>
          </tr>
          <tr>
            <td><label for="applyReason">申请事由：</label></td>
            <td valign="top">
            	<textarea name="applyReason" id="applyReason" cols="34" rows="6"><c:out value="${cost.applyReason }"/></textarea>
            	<font color="red">&nbsp;*&nbsp;&nbsp;</font>
            </td>
          </tr>  
          <tr>
            <td><label for="expectCost">预算金额：</label></td>
            <td>
            	<input type="text" name="expectCost" id="expectCost" value="${cost.expectCost }" onkeyup="this.value=this.value.replace(/[^0-9\.]/gi,'')"/>
            	<font color="red">&nbsp;*&nbsp;&nbsp;</font>
            </td>
          </tr>        
          <tr>
            <td><label for="actualCost">实际总额：</label></td>
            <td>
            	<input type="text" name="actualCost" id="actualCost" value="${cost.actualCost }" onkeyup="this.value=this.value.replace(/[^0-9\.]/gi,'')" disabled="disabled"/>
            </td>
          </tr>
          <tr>
            <td valign="top"><label for="actualDesc">实际细项描述：</label></td>
            <td>
            	<textarea name="actualDesc" id="actualDesc" cols="34" rows="6" disabled="disabled"><c:out value="${cost.actualDesc }"/></textarea>
            </td>
          </tr>   
          <tr>
            <td valign="top"><label for="wipeoutUser">报销人：</label></td>
            <td>
            	<input type="text" name="wipeoutUser" id="wipeoutUser" disabled="disabled" value="${cost.wipeoutUser }"/>
            </td>
          </tr>  
          <tr>
            <td valign="top"><label for="remark">备注信息：</label></td>
            <td valign="top"><textarea name="remark" id="remark" cols="34" rows="10"><c:out value="${cost.remark }"/></textarea></td>
          </tr>  
          <tr>
          <td><input type="hidden" id="status" name="status" value="0"></td>
          <td><input type="hidden" id="checkStatus" name="checkStatus" value="00"></td>
          </tr>
          <tr>
            <td></td>
            <td>
            	<input type="submit" id="btn_insert" value="提交" style="width:80px;" />
            	<input type="button" id="btn_back" value="返回" onclick="history.back();" style="width:80px;" />
            </td>
          </tr>
        </table>
      </form>
    </fieldset>
  </div>
</div>
</body>
</html>